package com.baosight.sczx.zm.ca.service;

import java.util.Calendar;

import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.Utils;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.ca.domain.VZMCA03;
import com.baosight.sczx.zm.ca.domain.ZMCA4101;

public class ServiceZMCA16 extends ServiceEPBase{
	/**
	 * 页面初始化，返回组织好的层级小代码
	 * 
	 * @param EiInfo
	 * @return EiInfo
	 */
	public EiInfo initLoad(EiInfo inInfo) {
		
		ZMCA4101 m4101 = new ZMCA4101();
		inInfo.addBlock(Utils.generateOutBlock("cmes.ca.config", m4101, inInfo, "ZMCA03.queryConfig", false));
		return inInfo;//return this.query(inInfo);
	}

	public EiInfo queryByIndex(EiInfo inInfo) {
		
		VZMCA03 m = new VZMCA03();
		Calendar currentTime = Calendar.getInstance(); 
		currentTime.add(Calendar.DATE, -1);
		int maxDay = currentTime.getActualMaximum(Calendar.DAY_OF_MONTH);
		
		//设置查询昨天计划量相关的参数
		StaticTools.setQueryParameters(inInfo, "fdMonthOfYesterday", currentTime.get(Calendar.MONTH)+1, true);
		StaticTools.setQueryParameters(inInfo, "fdDaysOfMonth", maxDay, true);
		
		EiInfo outInfo = super.query(inInfo, "ZMCA03.queryByIndex", m);	
		
		outInfo.set("dayOfYear", ""+(currentTime.get(Calendar.DAY_OF_YEAR)+1));
		outInfo.set("dayOfMonth", ""+(currentTime.get(Calendar.DAY_OF_MONTH)+1));
		inInfo.set("daysOfCurrentMonth", ""+maxDay);
		outInfo.set("year", ""+currentTime.get(Calendar.YEAR));
		
		return outInfo;
	}
	
	public EiInfo queryByMonthChart(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		
		String PlanYear = inInfo.getString("PlanYear");
		StaticTools.setQueryParameters(inInfo, "PlanYear", PlanYear, true);

		inInfo.addBlock(Utils.generateOutBlock("queryByMonthChart", m, inInfo, "ZMCA16.queryByMonthChart", false));

		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR));
		return inInfo;
	}
	
	public EiInfo queryByDayChart(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		
		String PlanYear = inInfo.getString("PlanYear");
		StaticTools.setQueryParameters(inInfo, "PlanYear", PlanYear, true);

		inInfo.addBlock(Utils.generateOutBlock("queryByDayChart", m, inInfo, "ZMCA16.queryByDayChart", false));

		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR)+1);
		inInfo.set("day", ""+(currentTime.get(Calendar.DAY_OF_MONTH)));
		inInfo.set("daysOfCurrentMonth", ""+currentTime.getActualMaximum(Calendar.DAY_OF_MONTH));
		return inInfo;
	}
	
	public EiInfo queryByHoleTypeChart(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		inInfo.addBlock(Utils.generateOutBlock("queryByHoleTypeChart", m, inInfo, "ZMCA16.queryByHoleTypeChart", false));
		return inInfo;
	}
	/**
	 * 暂时不用了
	 * @param inInfo
	 * @return
	 */
	public EiInfo queryWorkfaceByChart(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();

		inInfo.addBlock(Utils.generateOutBlock("result", m, inInfo, "ZMCA16.queryByWorkFaceChart2", false));

		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR));
		return inInfo;
	}
	
	
	public EiInfo queryByListView(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		String PlanType = inInfo.getString("PlanType");
		StaticTools.setQueryParameters(inInfo, "PlanType", PlanType, true);
		
		inInfo.addBlock(Utils.generateOutBlock("queryByDepartment", m, inInfo, "ZMCA16.queryByDepartment", false));
		inInfo.addBlock(Utils.generateOutBlock("queryByDepartmentA", m, inInfo, "ZMCA16.queryByDepartmentA", false));

		inInfo.addBlock(Utils.generateOutBlock("queryByWorkFace", m, inInfo, "ZMCA16.queryByWorkFace", false));
		inInfo.addBlock(Utils.generateOutBlock("queryByWorkFaceA", m, inInfo, "ZMCA16.queryByWorkFaceA", false));
		inInfo.addBlock(Utils.generateOutBlock("queryByHoleType", m, inInfo, "ZMCA16.queryByHoleType", false));
		inInfo.addBlock(Utils.generateOutBlock("queryByHoleTypeA", m, inInfo, "ZMCA16.queryByHoleTypeA", false));

		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR));
		return inInfo;
	}
	
}
